﻿using Architecture.Domain.Service;
using MediatR;
using Architeture.Domain;
using RBAC.ZhuBoLin.Application.Command.RoleCommand.Farminginfo;

namespace RBAC.ZhuBoLin.Application.CommandHandlers.RoleHandler.Farminginfo
{
    public class FarmingCreateCommandHandler : IRequestHandler<FarmingCreateCommand, int>
    {
        protected readonly IFarmingService farmingService;

        public FarmingCreateCommandHandler(IFarmingService farmingService)
        {
            this.farmingService = farmingService;
        }

        public async Task<int> Handle(FarmingCreateCommand request, CancellationToken cancellationToken)
        {
            return await farmingService.farmingAdd(new Farming() { GoodsInfoid = request.GoodsInfoid, variety = request.variety, Source = request.Source, farmingDay = request.farmingDay, Brand = request.Brand, Incharge = request.Incharge, issueTime = request.issueTime, Farmingid = request.Farmingid });
        }
    }
}
